#!/usr/bin/env python3
# -*- coding:utf-8 -*-

# ======================================================
# @File:  : startup
# @Author : forward_huan
# @Date   : 2023/11/1 21:26
# @Desc   :
# ======================================================
import logging
import os
import sys

from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication
from common.logger import addConsoleHandler, addFileHandler, logger
from common.utils.path_utils import getCacheDir, createDirPath

from image_to_base64.model.image_path import ImagePath
from image_to_base64.module.img_to_base64 import ImgToBase64


def get_log_path():
    log_path = os.path.join(getCacheDir(), "log", "tool_chest.log")
    createDirPath(log_path, is_dir=False)
    return log_path


def init_logger():
    logger.setLevel(logging.DEBUG)
    addConsoleHandler(logger)
    addFileHandler(logger, get_log_path())


def run():
    init_logger()
    logger.info("启动图片转base64")
    app = QApplication(sys.argv)
    main = ImgToBase64()
    main.setWindowIcon(QIcon(ImagePath.IMG_LOGO))
    main.show()
    sys.exit(app.exec_())


if __name__ == '__main__':
    run()
